package model

import (
	"github.com/lexkong/log"
	"time"
)

type Video struct {
	VId string `gorm:"column:v_id" json:"vid"`
	CreatedAt time.Time  `gorm:"column:createdAt" json:"-"`
	UpdatedAt time.Time  `gorm:"column:updatedAt" json:"-"`
	DeletedAt *time.Time `gorm:"column:deletedAt" json:"-"`
	FilePath string `gorm:"column:file_path" json:"Path"`
}

func (v *Video)TableName() string{
	return "tb_video"
}

func (v *Video) CreateVideo() error{
	return DB.Self.Create(&v).Error
}

func (v *Video) UpdateVideo() error {
	return DB.Self.Save(v).Error
}

func GetVideo(vid string) (*Video,error){
	v := &Video{}
	log.Infof(vid)
	DB.Self.Debug().Where(&Video{
		VId: vid,
	}).First(&v)
	return v,nil
}

